<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.User>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Create User</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">
        $(document).ready(function() {
            $("#UserForm").validate({
                rules: {
                    UserName: {
                        required: true
                    },
                    Email: {
                        required: true,
                        email: true
                    },
                    Password: {
                        required: true
                    },
                    ConfirmPassword: {
                        equalTo: "#Password"
                    },
                    FName: {
                        required: true
                    },
                    LName: {
                        required: true
                    }

                },
                messages: {
                    UserName: {
                        required: "UserName cannot be blank"
                    },
                    Email: {
                        required: "Email cannot be blank",
                        email: "Email must be valid"
                    },
                    Password: {
                        required: "Password cannot be blank"
                    },
                    ConfirmPassword: {
                        equalTo: "Confirm Password and Password must be the same"
                    },
                    FName: {
                        required: "First Name cannot be blank"
                    },
                    LName: {
                        required: "Last Name cannot be blank"
                    }
                }
            });
            $("#submit_view").click(function() {
                $("#IsRedirectToView").val("true");
            });
        });
    </script>

    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
   <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->
    <br />
    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm("Create", "User", FormMethod.Post, new { id = "UserForm" }))
       {%>
    <fieldset>
        <legend>Create User</legend>
        <p>
            <label for="RoleName">
                Select Role of User:</label>
            <%= Html.DropDownList("RoleName", new SelectList(System.Web.Security.Roles.GetAllRoles(), "Users")) %>
        </p>
        <p>
            <label for="UserName">
                Username:</label>
            <%= Html.TextBox("UserName") %>
            <%= Html.ValidationMessage("UserName")%>
        </p>
        <p>
            <label for="Password">
                Password:</label>
            <%= Html.Password("Password")%>
            <%= Html.ValidationMessage("Password")%>
        </p>
        <p>
            <label for="ConfirmPassword">
                Confirm password:</label>
            <%= Html.Password("ConfirmPassword")%>
            <%= Html.ValidationMessage("ConfirmPassword")%>
        </p>
        <p>
            <label for="Email">
                Email:</label>
            <%= Html.TextBox("Email") %>
            <%= Html.ValidationMessage("Email")%>
        </p>
        <p>
            <label for="FName">
                First Name:</label>
            <%= Html.TextBox("FName")%>
            <%= Html.ValidationMessage("FName")%>
        </p>
        <p>
            <label for="LName">
                Last Name:</label>
            <%= Html.TextBox("LName")%>
            <%= Html.ValidationMessage("LName")%>
        </p>
        <p>
            <label for="HPhone">
                Phone:</label>
            <%= Html.TextBox("HPhone")%>
            <%= Html.ValidationMessage("HPhone")%>
        </p>
        <p>
            <label for="Address1">
                Slot number or Address:</label>
            <%= Html.TextBox("Address1")%>
            <%= Html.ValidationMessage("Address1")%>
        </p>
        <p>
            <label for="CommunityId">
                Select community:</label>
            <%= Html.DropDownList("CommunityId", new SelectList(new MVCWeb.Models.HOACRMDataContext().Communities, "CommunityId", "Name"))%>
        </p>
        <p>
            <label for="Options">
                Select option:</label>
            <select name="Options" id="Options">
                <option value="HomeOwner">HomeOwner</option>
                <option value="Leaser">Leaser</option>
            </select>
        </p>
        <p>
         <label for="NewsLetter">
                Receive NewsLetter from <%= System.Configuration.ConfigurationManager.AppSettings["SiteName2"] %>:</label>
            <%= Html.CheckBox("NewsLetter")%>
            <%= Html.ValidationMessage("NewsLetter", "*")%>
        </p>
        <p>
            <label for="Active">
                Active:</label>
            <%= Html.CheckBox("Active") %>
            <%= Html.ValidationMessage("Active", "*") %>
        </p>
        <p>
            <%= Html.Hidden("IsRedirectToView")%>
            <input id="submit" name="submit" type="submit" value="Save & New" />
            <input id="submit_view" name="submit_view" type="submit" value="Save & View" />
            <input type="reset" value="Reset" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>
</asp:Content>
